import { MiddlewareConsumer, Module, NestModule, RequestMethod } from '@nestjs/common';
import { AdminController } from './admin.controller';
import { AdminService } from './admin.service';
import {TypeOrmModule} from '@nestjs/typeorm'
import { Admin } from './entityes/admin.entity';
import { Admin_Dat } from './entityes/admin_Dat.entity';
import {CounterMiddleware } from '../counter/counter.middleware'
import { BoyService } from '../boy/boy.service';

@Module({
  imports:[TypeOrmModule.forFeature([Admin,Admin_Dat])],
  controllers: [AdminController],
  providers: [AdminService,BoyService]
})
export class AdminModule implements NestModule{
  configure(consumer: MiddlewareConsumer){
    // 应用中间件到指定路由
    // 应用CounterMiddleware中间件到路径为'/admin'且请求方法为GET的路由
    consumer.apply(CounterMiddleware).forRoutes({path:'/admin',method:RequestMethod.GET})
    // 以上代码将CounterMiddleware中间件应用到了所有路径为'/admin'且请求方法为GET的路由上
  }
}
